<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head></head><body><font size="7"><center>Database API Documentation</font><br>
<font size="4">Micah Bright, Nic Lupfer, Arun Balaji Sivakumar</center><br><br>
<font face="courier">Introduction<br><br>
We have one Database class that maintains all the tables and its records.<br>
The Tables are implemented as a linked list with the first table being a dummy node.<br>
The records are also implemented as a linked list with the first record of each table being a dummy node.<br>


<b><font size="6"face="times">The Database API:</font></b><br><br>
#include &lt;iostream&gt;<br>
#include &lt;vector&gt;<br>
#include &lt;string&gt;<br><br>

<b>using namespace</b> std;<br><br>

<b>enum</b> FieldType{<br>
&nbsp;&nbsp;&nbsp;	StringType,<br>
&nbsp;&nbsp;&nbsp;  FloatType,<br>
&nbsp;&nbsp;&nbsp;  IntType<br>
};<br><br>

<i><font color="#4AA02C">//The Records have been implemented as a linked list</font></i><br>
<b>struct</b> Record{<br>
&nbsp;&nbsp;&nbsp;  <i><font color="#4AA02C">//The vector contains one record of values.</font></i><br>
&nbsp;&nbsp;&nbsp;  vector&lt;<b>void</b>*&gt; Record; <br>
&nbsp;&nbsp;&nbsp;  Record *next;<br>
};<br><br>

<i><font color="#4AA02C">//The tables have been implemented as a linked list.</font></i><br>
<b>struct</b> Table{<br>
&nbsp;&nbsp;&nbsp;  string TableName;<br>
&nbsp;&nbsp;&nbsp;  vector&lt;string&gt; AttributeName;<br>
&nbsp;&nbsp;&nbsp;  vector&lt;FieldType&gt; AttributeType;<br>
&nbsp;&nbsp;&nbsp;  <i><font color="#4AA02C">//To link a table with its records, each table has a pointer to its starting record.</font></i><br>
&nbsp;&nbsp;&nbsp;  Record *StartRec;<br>
&nbsp;&nbsp;&nbsp;  <b>int</b> key;<br>
&nbsp;&nbsp;&nbsp;  Table *next;<br>
&nbsp;&nbsp;&nbsp;  Table();<br>
&nbsp;&nbsp;&nbsp;  ~Table();<br>
};<br><br>

<b>class</b> Database{<br>
&nbsp;&nbsp;&nbsp; <b>private:</b><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Table *StartTable;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//gets a pointer to the table before the table of the same name</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Table *FindTable(string);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//gets a pointer to the record before the record with a matching key</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Record* FindRecord(string,<b>void</b>*);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//returns a vector of record pointer that match the value.</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vector&lt;Record*&gt; FindRecord(string TableName, string AttributeName, <b>void</b>* Value);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>void</b> InsertTable(Table*);<br>
&nbsp;&nbsp;&nbsp; <b>public:</b><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Database();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Query QueryObj;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Takes Tablename, the attribute names, the attribute types and the index of the primary key attribute as parameters.</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>void</b> CreateTable(string TableName, vector&lt;string&gt;&, vector&lt;fieldType&gt;&, <b>int</b>);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Deletes a table - takes a table name as its parameter.</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>void</b> DeleteTable(string TableName);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Inserts a record taking a vector of void pointers as its parameter.</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>bool</b> InsertRecord(string TableName, vector&lt;<b>void</b>*&gt; &toInsert);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Deletes a record in TableName which has the primary key RecordKey.</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>void</b> DeleteRecord(string TableName, <b>void</b>* RecordKey);<br>
};<br><br>


<b>class</b> Query{<br>
&nbsp;&nbsp;&nbsp; <b>private:</b><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Table *StartTable;<br>
&nbsp;&nbsp;&nbsp; <b>public:</b><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Query();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Query(Table*);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Returns a vector of Tables with the name from parameter</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>vector<Tabble></b> From(vector<string>);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Returns a Table of the Tuples that satisfy the Condition</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>Table</b> Where(Table*, Conidion);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Returns a Table of Tuples from the given Table with only the Attributes given</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>Table</b> Select(Table*, vector<string>);<br>
};<br><br>

<b>class</b> Condition{<br>
&nbsp;&nbsp;&nbsp; <b>private:</b><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//The value to be compared against</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string Value;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//The desired operation</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; string Operation;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//The type of the attribute being compared</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fieldType Type;<br>
&nbsp;&nbsp;&nbsp; <b>public:</b><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Condition();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Creates a conditon, given an operator and a value</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Condition(string, string);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <i><font color="#4AA02C">//Returns true if the given is true when compared by the operator to the value</font></i><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b>bool</b> Check(string);<br>
};<br><br>

</font></fields></body></html>